
--天赋按钮

class.spSelect = extends(class.button) {
    reload = true,

    new = function (parent,x,y,w,h)
        local panel = class.spSelect:builder 
        {
            parent = parent,
            x = x,
            y = y,
            w = w,
            h = h,
        }
        return panel
    end,
    init = function (self)
        class.button.init(self)
        self:set_normal_image([[textures\black32.blp]])
        self:set_highlight([[UI\Widgets\BattleNet\bnet-button01-highlight-mouse.blp]])

        self.title = self:add_text('血牛(1/3)',0,10,nil,30,12,5)
        self.tags = self:add_text('血牛',0,145,nil,30,10,5)
        self.icon = self:add_panel('1',(self.w-96)/2,45,96,96)
        self.text = self:add_text('内容介绍内容介绍内容介绍内容介绍内容介绍内容介绍内容介绍',self.w*0.15,180,self.w*0.7,self.h-200,8)
        self.extp = self:add_text('学习会自动替换英雄的的|cff00ffff伤害类型|r和|cffff00ff输出类型|r',self.w*0.15,self.h - 50,self.w*0.7,50,8)
        self.extp:set_color(0xffffcc00)

        return self
    end,
    set_data = function(self,skill)
        self.skill = skill
        self.icon:set_normal_image(skill.art)
        self.title:set_text(skill.title or skill.name)
        self.tags:set_text(skill.tags)
        self.text:set_text(format_obj(skill, skill.tip))
        self.extp:set_text(skill.ui_tip)
        
        --self.jb:set_text(('|cffffff00%s|r'):format(skill:get_tooltips('jb_name')))
    end,
}


local ui = class.select_panel.create('玩家-学习技能')
ui:set_level(99)
ui:set_select_button(3,class.spSelect,300,350)
ui:hide()

ac.sync:event '玩家-学习技能'(function(_,player,index)
    local info = player:get_data('选择技能信息')
    local temp = info and info[1]
    local func = info and info[2]
    if temp and func then
        func(temp[index],index)
    end
end)


ac.game:event '玩家-选择技能面板'(function(_,player,data,func)
    if #data==0 then
        log.error('选择技能面板-选项为0')
        return
    end
    player:set_data('选择技能信息',{data,func})
    if player:is_self() then
        ui:set_data(data)
        ui:show()
    end
end)
